/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is AST'r Framework.
  
  The Initial Developer of the Original Code is
  ALCARAZ Marc (aka eKameleon) <vegas@ekameleon.net>.
  Portions created by the Initial Developer are Copyright (C) 2004-2007
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  
*/

/**
 * The UserVo connected in the server-side application.
 */
if ( echat.vo.UserVO == undefined ) 
{

	/**
	 * @requires andromeda.model.AbstractValueObject
	 */
	require("andromeda.model.AbstractValueObject") ;
	
	/**
	 * Creates a new UserVO instance.
	 * @param name The optional name of the user.
	 * @param client The optional Client reference of the user.
	 */
	echat.vo.UserVO = function( name /*String*/ , client /*Client*/ )
	{
		
		andromeda.model.AbstractValueObject.call( this ) ; // super
		
		if ( arguments.length > 0 )
		{
			this.name   = name   || null ;
			this.client = client || null ;
			
			 // hack to find the user in the user model
			if (this.client != null)
			{
				this.client.name = this.name ;
				this.client.id   = this.id ;
			}
			 
		}
		
	}
	
	/**
	 * @extends andromeda.model.AbstractValueObject
	 */
	proto = echat.vo.UserVO.extend( andromeda.model.AbstractValueObject ) ;
	
	/**
	 * The Client reference of the user.
	 */
	proto.client /*Client*/ = null ;	
	
	/**
	 * The name of the user.
	 */
	proto.name /*String*/ = null ;

	/**
	 * Returns {@code true} if this object it's the same like the specified object in argument.
	 * @return {@code true} if this object it's the same like the specified object in argument.
	 */
	proto.equals = function( o )
	{
		if (o instanceof UserVO || o instanceof  echat.vo.UserVO )
		{
			return o.id == this.id ;			
		}
		else
		{
			return false ;
		}
	}
	
	/**
	 * Returns the string representation of this instance.
	 * @return the string representation of this instance
	 */
	proto.toString = function() /*String*/ 
	{
		return "[UserVO id:" + this.id + ", name:" + this.name + "]";
	}
	
	
	delete proto ;

}